package com.ptu.spzx.controller;

import com.github.pagehelper.PageInfo;
import com.ptu.spzx.domain.Course.Course;
import com.ptu.spzx.domain.Course.DTO.CourseDto;
import com.ptu.spzx.domain.Course.DTO.CourseSelectDto;
import com.ptu.spzx.domain.Course.Vo.CourseVo;
import com.ptu.spzx.domain.Delete.DeleteIds;
import com.ptu.spzx.model.vo.common.Result;
import com.ptu.spzx.model.vo.common.ResultCodeEnum;
import com.ptu.spzx.service.ICourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.*;

@RestController
@RequestMapping("/sc/exam/course")
public class CourseController {
    @Autowired
    private ICourseService iCourseService;
    //增加课程
    @PostMapping("/addCourse")
    public Result addCourse(@RequestBody CourseDto courseDto){
        iCourseService.addCourse(courseDto);
         return Result.build(null,ResultCodeEnum.SUCCESS);
    }
    //更新课程
    @PutMapping("/updateCourse")
    public Result updateCourse(@RequestBody CourseDto courseDto){
        iCourseService.updateCourse(courseDto);
        return Result.build(null,ResultCodeEnum.SUCCESS);
    }
    //删除课程
    @DeleteMapping("/deleteCourse")
    public Result deleteCourse(@RequestBody DeleteIds deleteIds){
        iCourseService.deleteCourse(deleteIds);
        return Result.build(null,ResultCodeEnum.SUCCESS);
    }
    //展示课程列表
    @GetMapping("/getCourseList/{teachId}/{pageNum}/{pageSize}")
    public Result getExamPaperByExamId(@PathVariable("teachId") Long teachId,
                                       @PathVariable("pageNum") Integer pageNum,
                                       @PathVariable("pageSize") Integer pageSize){
        PageInfo<Course> coursePageInfo=iCourseService.getCourseList(teachId,pageNum,pageSize);
        return Result.build(coursePageInfo,ResultCodeEnum.SUCCESS);
    }
    //课程的模糊查询
    @GetMapping(value = "/findByPage/{pageNum}/{pageSize}")
    public Result findByPage(@PathVariable("pageNum") Integer pageNum,
                             @PathVariable("pageSize") Integer pageSize,
                             @RequestBody CourseSelectDto courseSelectDto){
        PageInfo<Course> pageInfo = iCourseService.findByPage(pageNum,pageSize,courseSelectDto);
        return Result.build(pageInfo, ResultCodeEnum.SUCCESS);
    }
    //根据学生获取课程信息

}
